def _generate_digits(value_positive: int, radix: int):
    assert value_positive > 0
    assert radix > 1
    while value_positive > 0:
        yield value_positive % radix
        value_positive //= radix


def to_string(value: int, digit_chars: list[str]) -> str:
    radix = len(digit_chars)
    if radix <= 1:
        raise ValueError("不支持零进制或者一进制。")
    if value == 0:
        return digit_chars[0]

    sign = -1 if value < 0 else 1
    value *= sign

    digits = list(_generate_digits(value, radix))
    digits.reverse()

    result = "".join([digit_chars[digit] for digit in digits])
    if sign == -1:
        result = f"-{result}"
    return result


def to_number_string(value: int, radix: int) -> str:
    digit_chars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
    if radix < 0:
        raise ValueError("radix 不应该小于零。")
    return to_string(value, digit_chars[0:radix])
